package Group9.TodoManager.Actions;

import Group9.TodoManager.Data.SimpleListModel;

/**
 * SelectListAction is used for selecting an item in the pop up list
 * @author volkan cambazoglu
 *
 */
public class SelectListAction extends TodoManagerAction {
	
	private SimpleListModel listModel;

	/**
	 * Constructor. Creates an instance of the SelectListAction class.
	 * @param listModel listModel
	 */
	public SelectListAction(SimpleListModel listModel) {
		super();
		this.listModel = listModel;
	}

	/**
	 * When this action is executed, select the item and get its index.
	 * @param param
	 */
	@Override
	public void executeAction(Object param) {
		int rowIndex = Integer.parseInt(param.toString());
		listModel.setSelectedRowIndex(rowIndex);
        putValue("SELECTEDINDEX", rowIndex);
	}
}
